import Vue from 'vue'
import Vuex from 'vuex'
Vue.use(Vuex)

import products from './modules/products'
import search from './modules/search.js'
import cart from './modules/cart.js'

const store = new Vuex.Store({
  state: {
    tabIndex: 0,
    all: [],
 		count: 0,
 		num: [2,2],
 		login:false,
 		userinfo:{}
  },
  modules: {
    products,
    search,  //所有列表
    cart
  },
  mutations: {  
    addcart (state,{ amount }) {
      state.all.push( amount );
      this.state.num.push(1);
      console.log(this.state.num)
    },
    changeIndex(state, payload) {
      state.tabIndex = payload
    }
  },
  getters:{
  	getLoginStatus(state){
  		return state.login
  	},
  	getUserInfo(state){
  		return state.userinfo
  	}
  }
})

export default store
